package edu.bit.water.controller;

import edu.bit.water.entity.MetaDischarge;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;


import edu.bit.water.service.MetaDischargeService;

@Controller
@RequestMapping("/meta_discharge")
public class MetaDischargeController {

    @Autowired
    private MetaDischargeService metaDischargeService;

    @ResponseBody
    @RequestMapping(value = "/select", method=RequestMethod.GET)
    public Map<String, Object> queryDischarge() {
        Map<String, Object> result = new HashMap<>();
        List<MetaDischarge> list = metaDischargeService.queryDischarge();
        result.put("rows", list);
        return result;
    }

    @ResponseBody
    @RequestMapping("/insert")
    public Map<String, Object> insertMetaDischarge(MetaDischarge metaDischarge) {
        //metaDischarge.showContent();
        Map<String, Object> result = metaDischargeService.insertMetaDischargeService(metaDischarge);
        return result;
    }

    /**
     * 删除metaDischarge
     * author Page
     */
    @ResponseBody
    @RequestMapping("/delete")
    public Map<String, Object> deleteMetaDischarge(@RequestBody List<String>metaDischarges) {
        return metaDischargeService.deleteMetaDischarges(metaDischarges);
    }

    @ResponseBody
    @RequestMapping("/update")
    public Map<String, Object> updateMetaDischarge(MetaDischarge metaDischarge) {
        Map<String, Object> result = metaDischargeService.updateMetaDischargeService(metaDischarge);
        return result;
    }
}
